package com.wushi.lenovo.asia5b.app_widget;

import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.Guideline;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.wushi.lenovo.asia5b.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhangyuncai on 2019/2/18.
 */
public class LogisticsView extends ConstraintLayout {
    @BindView(R.id.guide_logistics_v)
    Guideline guide_logistics_v;
    @BindView(R.id.tv_logistics_text1)
    TextView tv_logistics_text1;
    @BindView(R.id.tv_logistics_text2)
    TextView tv_logistics_text2;
    @BindView(R.id.tv_logistics_text3)
    TextView tv_logistics_text3;
    @BindView(R.id.tv_logistics_line1)
    TextView tv_logistics_line1;
    @BindView(R.id.tv_logistics_line2)
    TextView tv_logistics_line2;
    @BindView(R.id.iv_logistics_circle1)
    ImageView iv_logistics_circle1;
    @BindView(R.id.iv_logistics_circle2)
    ImageView iv_logistics_circle2;
    @BindView(R.id.iv_logistics_circle3)
    ImageView iv_logistics_circle3;
    @BindView(R.id.iv_logistics_intransit1)
    ImageView iv_logistics_intransit1;
    @BindView(R.id.iv_logistics_intransit2)
    ImageView iv_logistics_intransit2;

    public LogisticsView(Context context) {
        super(context);
        init();
    }

    public LogisticsView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public LogisticsView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        View.inflate(getContext(), R.layout.view_logistics, this);
        ButterKnife.bind(this);
    }

    /**
     * 设置物流状态
     * @param status
     */
    public void setDeliveredStatus(int status) {
        iv_logistics_circle1.setImageResource(status > 0 ? R.drawable.ic_logistics_press : R.drawable.ic_logistics_normal);//status=1 2 3
        iv_logistics_circle2.setImageResource(status > 1 ? R.drawable.ic_logistics_press : R.drawable.ic_logistics_normal);//status=2 3
        iv_logistics_circle3.setImageResource(status > 2 ? R.drawable.ic_logistics_press : R.drawable.ic_logistics_normal);//status=3
        tv_logistics_line1.setSelected(status > 1);//status=2 3
        tv_logistics_line2.setSelected(status > 2);//status=3
        iv_logistics_intransit1.setVisibility(status ==1 ? VISIBLE : GONE);
        iv_logistics_intransit2.setVisibility(status ==2 ? VISIBLE : GONE);
        if (status == 0) {
        } else if (status == 1) {//抵达仓库

        } else if (status == 2) {//已发货

        } else if (status == 3) {//已签收

        }

    }
}
